import { ShellUtil } from "./ShellUtil";
import { Main } from "../Main";

/**
 * png压缩工具
 * @author 赵占涛
 */
export class PicCompressUtil {
    /** 压缩png */
    static compressPng(png:string, cb:()=>void) {
        ShellUtil.exec(`            
            ${Main.projPath}easyscript/lib/pngquant2.9.0/pngquant -s 1 -o ${png}.compress.png ${png} || exit 1
            mv -f ${png}.compress.png ${png} || exit 1
        `, () => {
            cb();
        });
    }
    /** 压缩jpg */
    static compressJpg(jpg:string, cb:()=>void) {
        ShellUtil.exec(`
            jpegoptim --strip-all --preserve --totals --all-progressive --max=80 ${jpg} || exit 1
        `, () => {
            cb();
        });
    }
}